import Vue from 'vue'
import Vuex from 'vuex'

import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'
import organization from './modules/organization'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    app,
    settings,
    user,
    organization
  },
  state: {
    userInfo: JSON.parse(sessionStorage.getItem('user_info') || '{}')
  },
  mutations: {
    SET_USER_INFO(state, data) {
      state.userInfo = data
      sessionStorage.setItem('user_info', JSON.stringify(data))
    }
  },
  actions: {},
  getters
})
